home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- import string
- import socket
- import os
- import sys
- __version__ = '1.10'
- MAXFTPCACHE = 10
- if os.name == 'mac':
- pathname2url
- elif os.name == 'nt':
- pathname2url
-
-
- def test1():
- import time
- s = ''
- for i in range(256):
- s = s + chr(i)
-
- s = s * 4
- t0 = time.time()
- qs = quote(s)
- uqs = unquote(qs)
- t1 = time.time()
- if uqs != s:
- print 'Wrong!'
-
- print `s`
- print `qs`
- print `uqs`
- print round(t1 - t0, 3), 'sec'
-
-
- def reporthook(blocknum, blocksize, totalsize):
- print 'Block number: %d, Block size: %d, Total size: %d' % (blocknum, blocksize, totalsize)
-
-
- def test(args = []):
- if not args:
- args = [
- '/etc/passwd',
- 'file:/etc/passwd',
- 'file://localhost/etc/passwd',
- 'ftp://ftp.python.org/etc/passwd',
- 'http://www.python.org/index.html']
-
-
- try:
- for url in args:
- print '-' * 10, url, '-' * 10
- (fn, h) = urlretrieve(url, None, reporthook)
- print fn, h
- if h:
- print '======'
- for k in h.keys():
- print k + ':', h[k]
-
- print '======'
-
- fp = open(fn, 'rb')
- data = fp.read()
- del fp
- if '\r' in data:
- table = string.maketrans('', '')
- data = string.translate(data, table, '\r')
-
- print data
- (fn, h) = (None, None)
-
- print '-' * 40
- finally:
- urlcleanup()
-
-
-
- def main():
- import getopt
- import sys
-
- try:
- (opts, args) = getopt.getopt(sys.argv[1:], 'th')
- except getopt.error:
- msg = None
- print msg
- print 'Use -h for help'
- return None
-
- t = 0
- for o, a in opts:
- pass
-
- if t:
- if t > 1:
- test1()
-
- test(args)
- elif not args:
- print 'Use -h for help'
-
- for url in args:
- print urlopen(url).read(),
-
-
- if __name__ == '__main__':
- main()
-
-